package com.dhj.streamTest.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
// 用于后期的去重使用
@EqualsAndHashCode
public class Author implements Comparable<Author> {

    //id
    private Long id;

    //姓名
    private String name;

    //年龄
    private Integer age;

    //简介
    private String intro;

    //作品
    private List<Book> books;


    /**
     * 本体-比较：升序
     * 比较-本体：降序
     */
    @Override
    public int compareTo(Author o) {
        return this.getAge() - o.getAge();
    }


}